/**
 *
 */
import { RouteRecordRaw } from "vue-router";
/**
 *
 */
import HomePage from "@/views/HomePage.vue";
/**
 *
 */
import {
  BarChartOutline,
  TrendingUp,
  ClipboardOutline,
  Cloudy,
  ColorFilter,
  ColorFilterOutline,
} from "@vicons/ionicons5";
/**
 * 路径名称
 */
import {
  HOME_PAGE,
  LOGIN_PAGE,
  ACQUIESCE_PAGE,
  INSPECTOR_PAGE,
  DATA_SERVICE_PAGE,
  DATA_MANAGE_PAGE,
  MODEL_MANAGE_PAGE,
  MODEL_TRAIN_PAGE,
  MODEL_MY_PAGE,
} from "@/common/constants";
/**
 *
 */
import { h } from "vue";
/**
 *
 */
import { NIcon } from "naive-ui";
/**
 *
 */
export const asideRoutes: RouteRecordRaw[] = [
  {
    path: "inspectors",
    name: INSPECTOR_PAGE,
    meta: {
      label: "平台概览",
      icon: () => h(NIcon, null, { default: () => h(TrendingUp) }),
      certificate: true,
    },
    component: () => import("@/views/Inspectors.vue"),
  },
  {
    path: "dataService",
    name: DATA_SERVICE_PAGE,
    meta: {
      label: "云数据服务",
      icon: () => h(NIcon, null, { default: () => h(Cloudy) }),
      certificate: true,
    },
    component: () => import("@/views/data/DataService.vue"),
    children: [
      {
        path: "data_manage",
        name: DATA_MANAGE_PAGE,
        meta: {
          label: "数据集管理",
          certificate: true,
        },
        component: () => import("@/views/data/manage/DataManage.vue"),
      },
    ],
  },
  {
    path: "modelManage",
    name: MODEL_MANAGE_PAGE,
    meta: {
      label: "模型管理",
      icon: () => h(NIcon, null, { default: () => h(ColorFilter) }),
    },
    component: () => import("@/views/model/ModelManage.vue"),
    children: [
      {
        path: "model_train",
        name: MODEL_TRAIN_PAGE,
        meta: {
          label: "模型训练",
          certificate: true,
        },
        component: () => import("@/views/model/train/ModelTrain.vue"),
      },
      {
        path: "model_my",
        name: MODEL_MY_PAGE,
        meta: {
          label: "我的模型",
          certificate: true,
        },
        component: () => import("@/views/model/my/ModelMy.vue"),
      },
    ],
  },
];
/**
 * 首页路由
 */
const authRoutes: RouteRecordRaw = {
  path: "/home",
  name: HOME_PAGE,
  component: HomePage,
  children: [
    {
      path: "",
      name: ACQUIESCE_PAGE,
      component: () => import("@/views/AcquiescePage.vue"),
    },
    ...asideRoutes,
  ],
};

/**
 * 主路由
 */
export const routes: RouteRecordRaw[] = [
  {
    path: "/",
    redirect: () => {
      return LOGIN_PAGE;
    },
  },
  authRoutes,
  {
    path: "/login",
    name: LOGIN_PAGE,
    component: () => import("@/views/LoginPage.vue"),
  },
  // 匹配不存在路由
  {
    path: "/:pathMatch(.*)*",
    redirect: (to) => {
      return {
        name: LOGIN_PAGE,
      };
    },
  },
];
